package com.aliyun.messagemgt.common.enums;

/**
 * @author lby
 * @Date 16:48 2019/5/5
 */
public enum TimeTypeEnum {
    /**
     *获取年月日时分秒数据
     */
    YEAR(1, "年份"),
    MONTH(2, "月份"),
    DAY(3, "天数"),
    HOUR(4, "小时"),
    MINUTE(5, "分钟"),
    SECOND(6, "秒数"),
    WEEKOFYEAR(7, "今天是一周的第几天");

    private final Integer value;
    private final String desc;

    TimeTypeEnum(final Integer value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    public Integer getValue() {
        return this.value;
    }

    public String getDesc() {
        return this.desc;
    }

    public String getEnumName() {
        return name();
    }

    /**
     * 获取对象实例
     *
     * @param key 键
     * @return
     */
    public static TimeTypeEnum valueofKey(Integer key) {
        for (TimeTypeEnum timeTypeEnum : values()) {
            if (timeTypeEnum.value.equals(key)) {
                return timeTypeEnum;
            }
        }
        throw new IllegalArgumentException("未查询到匹配实例对象：" + key);
    }
}
